package acessoDados.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;

import acessoDados.dao.AviaoDAO;

public class AviaoDAOImpl extends BaseDAOImpl implements AviaoDAO {
	public void criaAviao(String TipoAviao, int lotacao) throws SQLException, ClassNotFoundException {
		String query = "INSERT INTO aviao (TipoAviao, lotacao)" + "VALUES ('" + TipoAviao + "', " + lotacao + ");";
		executaQueryUpdate(query);
	}

	public  void editAviao(String id, String nome, String lotacao) throws SQLException, ClassNotFoundException {

			String query = "UPDATE aviao " +
					"SET " +
					"TipoAviao='" + nome +
					"', lotacao='" + lotacao +
					"' WHERE idAviao=" + id + ";";
			
			
			executaQueryUpdate(query);
	}

	public  void deleteAviao(String id) throws SQLException, ClassNotFoundException {
		String query = "DELETE FROM aviao WHERE idAviao=" + id + ";";

		
		executaQueryUpdate(query);
	}

	public  ResultSet getAvioes() throws SQLException, ClassNotFoundException {
		String query = "SELECT idAviao, TipoAviao FROM aviao;";
		return executaQuery(query);

	}

	public  ResultSet getDetalhesAviao(String idAviao) throws SQLException, ClassNotFoundException {
		String query = "SELECT * FROM aviao WHERE idAviao="+idAviao+";";
		return executaQuery(query);
	}

}
